//package com.william.springsecurity.handler;
//
//import cn.hutool.json.JSONUtil;
//import com.william.springsecurity.common.Result;
//import org.springframework.security.access.AccessDeniedException;
//import org.springframework.security.web.access.AccessDeniedHandler;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.io.PrintWriter;
//
//// 异常处理器 移入全局异常处理器
//@Component
//public class JwtAccessDeniedHandler implements AccessDeniedHandler {
//
//    @Override
//    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AccessDeniedException e) throws IOException, ServletException {
//        httpServletResponse.setContentType("application/json;charset=utf-8");
//        httpServletResponse.setStatus(HttpServletResponse.SC_FORBIDDEN);
//        PrintWriter out = httpServletResponse.getWriter();
//        Result result = Result.failed(HttpServletResponse.SC_FORBIDDEN,"请登录");
//        out.write(JSONUtil.toJsonStr(result));
//        out.flush();
//        out.close();
//    }
//}
